home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Technotools
/
Technotools (Chestnut CD-ROM)(1993).ISO
/
lang_c
/
mscfunct
/
com.doc
< prev
next >
Wrap
Text File
|
1987-05-08
|
2KB
|
82 lines
COM: port support functions for Microsoft C
#include <com.h>
char com_getc( port );
int port;
int com_init( port, baud, parity, stop, length );
int port, baud, parity, stop, length;
unsigned int com_putc( port, c );
int port; char c;
int com_ready( port );
int port;
int com_stat( port );
int port;
o Description
The com functions provide control over the serial ports of your PC.
The function com_getc waits until a character is present at the specified
serial port, and it then inputs the character and returns it.
The function com_init sets the baud rate, parity, stop bits and word length
of the specified serial port and returns the status word, as described
below.
The function com_putc outputs a character to the specified serial port
and returns the status word after attempting to send the character.
The function com_ready checks the serial port specified and returns a 1 if a
character is waiting or a 0 if there is no input waiting.
The function com_stat returns the status word for the specified port.
NOTES
-----
Status word bit assignments:
bit MASK Meaning
--- ---- -------
0 0x0001 Clear to Send has changed state
1 0x0002 Data Set Ready has changed state
2 0x0004 End of ringing pulse detector
3 0x0008 Carrier Detect signal has changed state
4 0x0010 Clear to Send signal
5 0x0020 Data Set Ready signal
6 0x0040 Ringing indicator
7 0x0080 Carrier Detect signal
8 0x0100 Received data is ready
9 0x0200 Overrun error (previous character not read & a new
character has arrived)
10 0x0400 Parity error (in incoming data)
11 0x0800 Framing error (an incorrect start/stop bit was received)
12 0x1000 Break detect
13 0x2000 Transmitter holding register empty (ready for another character
to transmit)
14 0x4000 Transmitter shift register empty (not currently transmitting)
15 0x8000 Time-out error
com_init values for baud, parity, stop, and length
baud: 0 = 110 baud; 1 = 150 baud; 2 = 300 baud; 3 = 600 baud;
4 = 1200 baud; 5 = 2400 baud; 6 = 4800 baud; 7 = 9600 baud.
parity: 0 = no parity; 1 = odd parity; 2 = no parity; 3 = even parity.
stop: 0 = 1 stop bit; 1 = 2 stop bits.
length: 0 = 5-bit words; 1 = 6-bit words; 2 = 7-bit words; 3 = 8-bit words.